//alert('run');
function imgClick(o)
{
	if(o)
	{
		var isSign=document.getElementById("group_0").className=="current";
		if(isSign)
		{
			parent.pharaoh_img2_AddSign(o);
		}
		else
		{
			parent.pharaoh_img2_AddImgToPage(o);
		}
	}
}

document.body.oncontextmenu=function()
{
	window.event.returnValue=false;
	return false;
}
	

var LastClickID=null;

function groupClick(o)
{
	if(o)
	{

		if(o.className=='current') return;
		if(LastClickID)
		{
			document.getElementById(LastClickID).className="";
		}
		try
		{
		document.getElementById("group_0").className="";
		document.getElementById("group_1").className="";
		}
		catch(e){}
		LastClickID=o.id;
		o.className='current';		
		parent.pharaoh_img2_GroupChanged(o.id.split("_")[1]);
		/*
		document.getElementById(LastClickID).className="";
		LastClickID=o.id;
		o.className='current';
		parent.pharaoh_img2_GroupChanged(LastClickID.split("_")[1]);
		*/
	}
}

function showImg(o)
{
	o.className="curImg";	
	if(window.event.ctrlKey) return;
	var isSign=document.getElementById("group_0").className=="current";
	var id=o.id.split('_')[1];
	//id=(id-1)%15;
	id=(id-1)%parent.pharaoh_Config.X;
	var imgID='leftImg';
	if(id<(parent.pharaoh_Config.X/2))
	{
		imgID='rightImg';
	}
	var txt=o.src;
	if(txt)
	{	
		var imgShow=document.getElementById(imgID);
		//imgShow.style.display='block';
		//imgShow.title=o.title;
		if(isSign)
		{
			imgShow.innerText=txt;
			imgShow.style.backgroundColor ='#FFFFE7';
		}
		else
		{
			imgShow.innerHTML="<img src='"+txt+"' />";
			imgShow.style.backgroundColor ='#FFF';	
			imgShow.style.display='block';	
		}
	}
	
}

function hideImg(o)
{
	document.getElementById('leftImg').style.display='none';
	document.getElementById('rightImg').style.display='none';
	o.className="";
}

function MoveTab(nub)
{
	//alert(nub);
	var oUL=document.getElementById("tabUL");
	if(nub>0)
	{
		//"group_"+pharaoh_img2_GroupNames.length
		
		if(oUL.style.posLeft>=0) {return;}
	}
	else
	{
		//offsetLeft
		var rightTab = document.getElementById("group_"+parent.pharaoh_img2_GroupNames.length);
		if(rightTab.getBoundingClientRect().right<document.body.clientWidth-20) {return;}
		//parent.document.title= (rightTab.getBoundingClientRect().right+"/"+document.body.clientWidth);
		
		//getBoundingClientRect
	}
	oUL.style.posLeft+=nub;
}
